Source Code Viewer - Example 2 - AbstractDetailDisplay

package name.matthewgreet.example2.common;

import java.io.Serializable;

public abstract class AbstractDetailDisplay<D,T extends Serializable> {
	private ListCache<?,T> listCache;
	private D formattedRecord;
	
	private int recordNo;
	private int listSize;
	private int pageNo;
	private int pageSize;
	private int totalPages;
	
	public AbstractDetailDisplay(ListCache<?,T> listCache) {
		this.listCache = listCache;
	}
	
	protected void formatEnd(ListCache<?,T> listCache) {
		// Empty
	}
	
	protected abstract D formatRecord(T record);
	
	protected void formatStart(ListCache<?,T> listCache) {
		// Empty
	}
	
	
	public void init() throws Exception {
		recordNo = listCache.getSelectedIndex() + 1;
		listSize = listCache.getListSize();
		pageNo = listCache.getPageNo();
		pageSize = listCache.getPageSize();
		totalPages = listCache.getTotalPages();
		
		formatStart(listCache);
		formattedRecord = formatRecord(listCache.getSelected());
		formatEnd(listCache);
	}
	
	
	public D getFormattedRecord() {
		return formattedRecord;
	}
	public int getRecordNo() {
		return recordNo;
	}
	public int getListSize() {
		return listSize;
	}
	public int getPageNo() {
		return pageNo;
	}
	public int getPageSize() {
		return pageSize;
	}
	public int getTotalPages() {
		return totalPages;
	}
	
}